package com.wz.customerserv.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.wz.customerserv.feign.ProducerService;
import com.wz.customerserv.service.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private ProducerService producerService;

    @SentinelResource(value = "changeValueLimit", blockHandler = "changeValueFlow")
    public String changeValue(String name) {
        String res = "";

        res = producerService.addPrefix(name);

        return res;
    }

    public String changeValueFlow(String name, BlockException blockException) {
        log.info("changeValue接口被限流");
        return name;
    }
}
